package com.zyj.eps.mytest.service;

import com.zyj.eps.mapper.UserMapper;
import com.zyj.eps.pojo.Manager;
import com.zyj.eps.pojo.User;
import com.zyj.eps.service.ManagerService;
import com.zyj.eps.service.UserService;
import com.zyj.eps.service.UserServiceImpl;
import com.zyj.eps.util.IDutil;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @author super
 * @date 2022/3/22 20:58
 */
public class mytest {
    @Test
    public void addUser(){
        ApplicationContext Context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userServiceImpl = Context.getBean("userServiceImpl", UserService.class);
        User user = new User();
        user.setUserID(IDutil.GetUUID());
        user.setUname("王亚磊");
        user.setPassword("1234567");
        user.setAddress("zut");
        user.setSex("男");
        user.setAge(22);
        user.setTel("16271626166");
        user.setHealth("健康-已接种");
        System.out.println(user);
        userServiceImpl.addUser(user);
    }
    @Test
    public void getUser(){
        ApplicationContext Context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userServiceImpl = Context.getBean("userServiceImpl", UserService.class);
        List<User> list = userServiceImpl.getAllUser();
        System.out.println(list);
    }
    @Test
    public void getNews(){
        ApplicationContext Context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userServiceImpl = Context.getBean("userServiceImpl", UserService.class);
        System.out.println(userServiceImpl.getNews(2));
    }
    @Test
    public void ALL(){
        ApplicationContext Context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserMapper userMapper = Context.getBean("userMapper", UserMapper.class);
        System.out.println(userMapper.getAllUserByHealth());
    }
    @Test
    public void addManager(){
        ApplicationContext Context = new ClassPathXmlApplicationContext("applicationContext.xml");
        ManagerService managerServiceImpl = Context.getBean("managerServiceImpl", ManagerService.class);
        Manager manager = new Manager();
        manager.setManagerID(IDutil.GetUUID());
        manager.setMname("qqqqqq");
        manager.setSex("na");
        manager.setTel("1111111");
        manager.setHealth("aahahah");
        manager.setPassword("121212");
        managerServiceImpl.addManager(manager);
    }
}
